<?php


namespace app\common\model;


class Admin extends ModelBase
{
    public function getAdminInfo($where, $field = '*')
    {
        $info = $this->where($where)->field($field)->where('status', '<>', -1)->find();

        return $info ? $info->toArray() : [];
    }


    public function adminGetList($where = [], $field = 'm.*,b.nickname as leader_nickname', $order = '', $paginate = DB_LIST_ROWS){

        $list = $this->alias('m')->field($field)->leftJoin(SYS_DB_PREFIX . 'admin b', 'm.leader_id = b.id')->leftJoin(SYS_DB_PREFIX . 'AuthGroupAccess aga', 'm.id = aga.admin_id')->leftJoin(SYS_DB_PREFIX . 'AuthGroup ag', 'ag.id = aga.group_id')->where($where)->where('m.' . DATA_STATUS_NAME,'<>', (int)DATA_DELETE)->order($order)->select();

        $list = !empty($list) ? $list->toArray() : [];
        return $list;


    }


    /**
     * set admin info
     * @param $data
     * @param $where
     * @return bool
     */
    public function updateAdminInfo($data, $where)
    {

        return $this->where($where)->update($data);
    }

    public function getAddId($data){
      return  $this->insertGetId($data);
    }

}